var q = require('q');
var request = require('request').defaults({
    json: true
});
var config = require('./../config.json');


/** 获取工况的分组列表 */
exports.getStatusGroup = function () {
    var _this = this;
    var defer = q.defer();
    var url = config.apiUrl + "/ProjectStatusGroup";
    request({
        url: url,
        qs: {
            prjId: _this.prjId
        }
    }, function (error, response, body) {
        if (!error && response.statusCode === 200) {
            if (typeof (body) === 'string') {
                body = JSON.parse(body);
            }
            _this.statusGroup = body;
            defer.resolve(body);
        } else {
            defer.resolve([]);
        }
    });
    return defer.promise;
}